@extends('layouts.layout')

@section('title', '用户列表')

@section('CONTENT')
    <div class="box">
        <div class="box-body">
        </div>
    </div>
    <div class="box">
        <div class="box-header with-border">
            <h3 class="box-title">用户列表</h3>
            <div class="box-tools">
                @can('create-user')
                <a href="{{ route('register') }}" class="btn btn-default btn-sm">添加用户</a>
                @endcan
            </div>
        </div>
        <!-- /.box-header -->
        <div class="box-body">
            @if( count($users) )
                    <table class="table table-bordered">
                        <tr>
                            <th>ID</th>
                            <th>名字</th>
                            <th>邮箱</th>
                            <th>角色</th>
                            <th>创建时间</th>
                            <th style="width: 200px">操作</th>
                        </tr>
                            @foreach($users as $user)
                                <tr>
                                    <td>{{ $user->id }}</td>
                                    <td>{{ $user->name }}</td>
                                    <td>{{ $user->email }}</td>
                                    <td>
                                        @php
                                         $roles = $user->roles
                                        @endphp
                                        @foreach($roles as $role)
                                            <lable class="btn btn-xs btn-info disabled">{{ $role->cn_name }}</lable>
                                        @endforeach
                                    </td>
                                    <td>{{ $user->created_at }}</td>
                                    <td>
                                        @if( auth()->user()->can('show-user') || auth()->user()->can('edit-user'))
                                            <a href="{{ route('user.edit',['id'=>$user->id]) }}" class="btn btn-default btn-sm">查看编辑</a>
                                        @endif

                                        @can('update-user-password')
                                                <a href="{{ route('user.up-pwd',['id'=>$user->id])  }}" class="btn btn-default btn-sm">修改密码</a>
                                        @endcan

                                        <a href="" class="btn btn-default btn-sm">删除</a>
                                    </td>
                                </tr>
                            @endforeach
                    </table>
                @else
                    <h5>还没有用户哟，赶快去添加吧！</h5>
                @endif
        </div>
        <!-- /.box-body -->
        <div class="box-footer clearfix">
            {{--{{ $articles->links() }}--}}
        </div>
    </div>
@endsection